package com.hxkj.dao.impl;

import com.hxkj.dao.UserFootprintDao;
import com.hxkj.domain.po.UserFootprint;
import com.hxkj.mapper.UserFootprintMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * created by kezhijie on 2018/8/27 18:05.
 * email to kezhijie@hxoss.com
 */
@Service
public class UserFootprintDaoImpl implements UserFootprintDao {

    @Autowired
    private UserFootprintMapper userFootprintMapper;

    @Override
    public int save(UserFootprint userFootprint) {

        userFootprint.setCreateTime(System.currentTimeMillis());
        userFootprint.setUpdateTime(System.currentTimeMillis());
        userFootprint.setDelTag("0");

        return userFootprintMapper.insertSelective(userFootprint);
    }

    @Override
    public List<UserFootprint> selectList(UserFootprint userFootprint) {
        List<UserFootprint> userFootprints = userFootprintMapper.selectListByUserId(userFootprint);

        for (UserFootprint userFootprint1 : userFootprints) {
            if ((!userFootprint1.getSiteUrl().startsWith("http://")) && (!userFootprint1.getSiteUrl().startsWith("https://")))
                userFootprint1.setSiteUrl("http://" + userFootprint1.getSiteUrl());
        }
        return userFootprints;
    }
}
